<?php

namespace app\index\controller;

use app\index\model\SubCategory;
use app\index\model\SupCategory;
use app\index\service\CategoryService;
use app\index\service\QuotaService;
use app\index\service\UrlService;
use think\Controller;
use think\Request;

class Quota extends BaseController
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        //
        $category_list = CategoryService::getSupCategoryList();
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("category_list",$category_list);
        $this->assign("thirdurl_list",$url_list);
        return $this->fetch("getPrice");
    }

    public function getpriceList($options)
    {
        //
        $option_array = explode("-",$options);
        $supCateId=$option_array[0];
        $subCateId = $option_array[1];
        $category_list = CategoryService::getSupCategoryList();
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("category_list",$category_list);
        $this->assign("thirdurl_list",$url_list);
        $quota_list = QuotaService::getSubCateQuotaList($subCateId);
        $this->assign("quota_list",$quota_list);
        $supcategory_name = SupCategory::getCategoryNameById($supCateId);
        $subcategory_name = SubCategory::getCategoryNameById($subCateId);
        $this->assign("supcategory_name",$supcategory_name);
        $this->assign("subcategory_name",$subcategory_name);
        $this->assign("supCateId",$supCateId);
        $this->assign("subCateId",$subCateId);

        return $this->fetch("getpriceList");
    }

    public function getDeitail($options){
//        $option_array = explode("-",$options);
//        $supCateId=$option_array[0];
//        $subCateId = $option_array[1];
//        $level = $option_array[2];
//
//
//        $supcategory_name = SupCategory::getCategoryNameById($supCateId);
//        $subcategory_name = SubCategory::getCategoryNameById($subCateId);
//        $level_name = config("category.level.$level");
//        $year = config("app.year");
//        return $this->fetch("getPriceDetail",["supCateId"=>$supCateId,
//            "subCateId"=>$subCateId,"supcategory_name"=>$supcategory_name,
//            "subcategory_name"=>$subcategory_name,"year"=>$year]);
        $category_list = CategoryService::getSupCategoryList();
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("category_list",$category_list);
        $this->assign("thirdurl_list",$url_list);
        $quota_detail = QuotaService::getMutilQuotaDetail($options);
        $this->assign("quota_detail",$quota_detail);
        $year = config("app.year");
        return $this->fetch("getPriceDetail",[
           "idIndex"=>"1","options"=>$options,"year"=>$year]);
    }
    
    public function getDeitailList($supCateId,$subCateId){
    		return $this->fetch("getPriceDtList",["supCateId"=>$supCateId,
            "subCateId"=>$subCateId]);
        return $this->fetch("getPriceDtList");
    }
    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        //
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
